<?php
//包含数据库配置文件
include '../public/dbconfig.php';
//包含函数库文件
include '../public/func.inc.php';

$link = conn();
//var_dump($link);
session_start();


$pid = $_SESSION['id'];
$title = $_GET['title'];
$content = $_POST['content'];
$uid = $_SESSION['uid'];
//var_dump($pid);
//exit;
$ptime = time();
//获取发表IP
$pip = $_SERVER['REMOTE_ADDR'];
//var_dump($pip);
//exit;


if($pip == '::1'){
	$pip = '127.0.0.1';
}
//数据表中的ip为int
$longip =ip2long($pip);
//var_dump($longip);
//exit;
$sql = "insert into bbs_reply(pid,content,ptime,pip,uid) values('{$pid}','{$content}','{$ptime}','{$longip}','{$uid}')";
//var_dump($sql);
//exit;
$res = mysqli_query($link,$sql);
//var_dump($res);
//exit;
if($res){
	echo '<script>alert("回帖成功");window.location.href="huitiecg.php";</script>';
}else{
	echo '<script>alert("回帖失败");window.location.href="fatie.php";</script>';
	
}
mysqli_close($link);









?>